package com.aspose.cells;

class znj extends zbz {
   private int e = 1048575;
   private int f = 16383;
   private Worksheet g;
   private int h = 0;
   int a = 0;
   int d = 0;
   private Validation i = null;
   private int j;

   znj(Worksheet var1) {
      this.c(446);
      this.g = var1;
   }

   boolean a(Validation var1) {
      if (var1.a()) {
         return false;
      } else {
         this.i = var1;
         this.d = var1.getAreaList().size();

         int var2;
         for(var2 = 0; var2 < var1.getAreaList().size(); ++var2) {
            CellArea var3 = (CellArea)var1.getAreaList().get(var2);
            if (var3.StartRow < this.e) {
               this.e = var3.StartRow;
               this.f = var3.StartColumn;
            }
         }

         if (this.d == 0) {
            return false;
         } else {
            byte var10 = 14;
            byte[] var11 = zakq.a(var1.getInputTitle());
            var2 = var10 + this.c(var11);
            byte[] var4 = zakq.a(var1.getInputMessage());
            var2 += this.c(var4);
            byte[] var5 = zakq.a(var1.getErrorTitle());
            var2 += this.c(var5);
            byte[] var6 = zakq.a(var1.getErrorMessage());
            var2 += this.c(var6);
            byte[] var7 = null;
            if (var1.getType() != 0 && (var1.getFormula1() != null && !"".equals(var1.getFormula1()) || var1.d() != null)) {
               var7 = var1.d();
            }

            if (var7 != null) {
               var2 += var7.length;
            }

            byte[] var8 = null;
            if ((var1.getOperator() == 0 || var1.getOperator() == 7) && var1.getType() != 3 && var1.getType() != 7 && var1.getType() != 0) {
               var8 = var1.e();
            }

            if (var8 != null) {
               var2 += var8.length;
            }

            this.a = (8224 - var2) / 8;
            if (this.d > this.a) {
               var2 += this.a * 8;
            } else {
               var2 += this.d * 8;
            }

            this.a((short)var2);
            this.c = new byte[var2];
            switch(var1.getType()) {
            case 0:
            default:
               break;
            case 1:
               this.c[0] = 1;
               break;
            case 2:
               this.c[0] = 2;
               break;
            case 3:
               this.c[0] = 3;
               if (!var1.getInCellDropDown()) {
                  this.c[1] = 2;
               }

               if (var7 != null && var7.length > 0 && var7[0] == 23) {
                  if (var7[2] == 0) {
                     if (var7.length == (var7[1] & 255) + 3) {
                        this.c[0] = (byte)(this.c[0] | 128);
                     }
                  } else if (var7[2] == 1 && var7.length == 2 * (var7[1] & 255) + 3) {
                     this.c[0] = (byte)(this.c[0] | 128);
                  }
               }
               break;
            case 4:
               this.c[0] = 4;
               break;
            case 5:
               this.c[0] = 5;
               break;
            case 6:
               this.c[0] = 6;
               break;
            case 7:
               this.c[0] = 7;
            }

            switch(var1.getAlertStyle()) {
            case 0:
               this.c[0] = (byte)(this.c[0] | 32);
               break;
            case 2:
               this.c[0] = (byte)(this.c[0] | 16);
            }

            if (var1.getIgnoreBlank()) {
               this.c[1] = (byte)(this.c[1] | 1);
            }

            if (var1.getShowInput()) {
               this.c[2] = 4;
            }

            if (var1.getShowError()) {
               this.c[2] = (byte)(this.c[2] | 8);
            }

            switch(var1.getOperator()) {
            case 1:
               this.c[2] = (byte)(this.c[2] | 32);
               break;
            case 2:
               this.c[2] = (byte)(this.c[2] | 64);
               break;
            case 3:
               this.c[2] = (byte)(this.c[2] | 96);
               break;
            case 4:
               this.c[2] = (byte)(this.c[2] | 80);
               break;
            case 5:
               this.c[2] = (byte)(this.c[2] | 112);
            case 6:
            default:
               break;
            case 7:
               this.c[2] = (byte)(this.c[2] | 16);
               break;
            case 8:
               this.c[2] = (byte)(this.c[2] | 48);
            }

            byte var9 = 4;
            int var12;
            if (var11 == null) {
               this.c[var9] = 1;
               var12 = var9 + 4;
            } else {
               System.arraycopy(com.aspose.cells.b.a.zc.a(var1.getInputTitle().length()), 0, this.c, var9, 2);
               if (var1.getInputTitle().length() != var11.length) {
                  this.c[var9 + 2] = 1;
               }

               var12 = var9 + 3;
               System.arraycopy(var11, 0, this.c, var12, var11.length);
               var12 += var11.length;
            }

            if (var5 == null) {
               this.c[var12] = 1;
               var12 += 4;
            } else {
               System.arraycopy(com.aspose.cells.b.a.zc.a(var1.getErrorTitle().length()), 0, this.c, var12, 2);
               if (var1.getErrorTitle().length() != var5.length) {
                  this.c[var12 + 2] = 1;
               }

               var12 += 3;
               System.arraycopy(var5, 0, this.c, var12, var5.length);
               var12 += var5.length;
            }

            if (var4 == null) {
               this.c[var12] = 1;
               var12 += 4;
            } else {
               System.arraycopy(com.aspose.cells.b.a.zc.a(var1.getInputMessage().length()), 0, this.c, var12, 2);
               if (var1.getInputMessage().length() != var4.length) {
                  this.c[var12 + 2] = 1;
               }

               var12 += 3;
               System.arraycopy(var4, 0, this.c, var12, var4.length);
               var12 += var4.length;
            }

            if (var6 == null) {
               this.c[var12] = 1;
               var12 += 4;
            } else {
               System.arraycopy(com.aspose.cells.b.a.zc.a(var1.getErrorMessage().length()), 0, this.c, var12, 2);
               if (var1.getErrorMessage().length() != var6.length) {
                  this.c[var12 + 2] = 1;
               }

               var12 += 3;
               System.arraycopy(var6, 0, this.c, var12, var6.length);
               var12 += var6.length;
            }

            if (var7 == null) {
               var12 += 4;
            } else {
               System.arraycopy(com.aspose.cells.b.a.zc.a(var7.length), 0, this.c, var12, 2);
               var12 += 4;
               System.arraycopy(var7, 0, this.c, var12, var7.length);
               var12 += var7.length;
            }

            if (var8 == null) {
               var12 += 4;
            } else {
               System.arraycopy(com.aspose.cells.b.a.zc.a(var8.length), 0, this.c, var12, 2);
               var12 += 4;
               System.arraycopy(var8, 0, this.c, var12, var8.length);
               var12 += var8.length;
            }

            this.h = var12;
            return true;
         }
      }
   }

   boolean a() {
      int var1 = this.d - this.j > this.a ? this.a : this.d - this.j;
      if (var1 == 0) {
         return false;
      } else {
         int var2 = this.h;
         this.a((short)(var2 + 2 + var1 * 8));
         if (this.d() < this.c.length) {
            byte[] var3 = new byte[this.d()];
            System.arraycopy(this.c, 0, var3, 0, var3.length);
            this.c = var3;
         }

         System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, this.c, var2, 2);
         var2 += 2;

         for(int var6 = 0; var6 < var1; ++var6) {
            Object var4 = this.i.getAreaList().get(var6 + this.j);
            if (var4 instanceof CellArea) {
               CellArea var5 = (CellArea)var4;
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.StartRow), 0, this.c, var2, 2);
               var2 += 2;
               System.arraycopy(com.aspose.cells.b.a.zc.a(var5.EndRow), 0, this.c, var2, 2);
               var2 += 2;
               this.c[var2] = (byte)var5.StartColumn;
               var2 += 2;
               this.c[var2] = (byte)var5.EndColumn;
               var2 += 2;
            }
         }

         this.j += var1;
         return true;
      }
   }

   private int c(byte[] var1) {
      return var1 == null ? 4 : var1.length + 3;
   }

   Validation a(byte[] var1) throws Exception {
      Validation var2 = new Validation(this.g.getValidations());
      int var3 = var1[0] & 255 & 15;
      switch(var3) {
      case 0:
         var2.setType(0);
         break;
      case 1:
         var2.setType(1);
         break;
      case 2:
         var2.setType(2);
         break;
      case 3:
         var2.setType(3);
         break;
      case 4:
         var2.setType(4);
         break;
      case 5:
         var2.setType(5);
         break;
      case 6:
         var2.setType(6);
         break;
      case 7:
         var2.setType(7);
      }

      var3 = var1[0] & 255 & 112;
      switch(var3) {
      case 0:
         var2.setAlertStyle(1);
         break;
      case 16:
         var2.setAlertStyle(2);
         break;
      case 32:
         var2.setAlertStyle(0);
      }

      var3 = var1[1] & 255 & 1;
      if (var3 != 0) {
         var2.setIgnoreBlank(true);
      } else {
         var2.setIgnoreBlank(false);
      }

      var3 = var1[1] & 255 & 2;
      if (var3 == 0) {
         var2.setInCellDropDown(true);
      } else {
         var2.setInCellDropDown(false);
      }

      var3 = ((var1[2] & 255 & 3) << 6) + ((var1[1] & 255 & 252) >> 2);
      switch(var3) {
      case 0:
         var2.a(0);
         break;
      case 1:
         var2.a(1);
         break;
      case 2:
         var2.a(2);
         break;
      case 3:
         var2.a(3);
         break;
      case 4:
         var2.a(4);
         break;
      case 5:
         var2.a(5);
         break;
      case 6:
         var2.a(6);
         break;
      case 7:
         var2.a(7);
         break;
      case 8:
         var2.a(8);
         break;
      case 9:
         var2.a(9);
         break;
      case 10:
         var2.a(10);
         break;
      default:
         var2.a(0);
      }

      var3 = var1[2] & 255 & 4;
      if (var3 == 0) {
         var2.setShowInput(false);
      } else {
         var2.setShowInput(true);
      }

      var3 = var1[2] & 255 & 8;
      if (var3 == 0) {
         var2.setShowError(false);
      } else {
         var2.setShowError(true);
      }

      var3 = var1[2] & 255 & 240;
      switch(var3) {
      case 0:
         var2.setOperator(0);
         break;
      case 16:
         var2.setOperator(7);
         break;
      case 32:
         var2.setOperator(1);
         break;
      case 48:
         var2.setOperator(8);
         break;
      case 64:
         var2.setOperator(2);
         break;
      case 80:
         var2.setOperator(4);
         break;
      case 96:
         var2.setOperator(3);
         break;
      case 112:
         var2.setOperator(5);
      }

      byte var4 = 4;
      int[] var5 = new int[]{var4};
      var2.setInputTitle(this.a(var1, var5));
      int var12 = var5[0];
      var5[0] = var12;
      var2.setErrorTitle(this.a(var1, var5));
      var12 = var5[0];
      var5[0] = var12;
      var2.setInputMessage(this.a(var1, var5));
      var12 = var5[0];
      var5[0] = var12;
      var2.setErrorMessage(this.a(var1, var5));
      var12 = var5[0];
      int var6 = var1[var12] & 255;
      boolean var7 = false;
      boolean var8 = false;
      var6 = com.aspose.cells.b.a.zc.e(var1, var12) & '\uffff';
      var12 += 4;
      if (var6 != 0) {
         var2.a(new byte[var6]);
         System.arraycopy(var1, var12, var2.d(), 0, var6);
         var12 += var6;
      }

      var6 = com.aspose.cells.b.a.zc.e(var1, var12) & '\uffff';
      var12 += 4;
      if (var6 != 0) {
         var2.b(new byte[var6]);
         System.arraycopy(var1, var12, var2.e(), 0, var6);
         var12 += var6;
      }

      int var9 = com.aspose.cells.b.a.zc.e(var1, var12);
      if ((var9 & '\uffff') == 0) {
         return null;
      } else {
         int var13;
         this.e = var13 = com.aspose.cells.b.a.zc.e(var1, var12 + 2) & '\uffff';
         int var14;
         this.f = var14 = var1[var12 + 6] & 255;
         if (var2.d() != null) {
            var2.a(Validation.a(this.g.c(), var2.d(), 0, var2.getType(), var13, var14));
         }

         if (var2.e() != null) {
            var2.b(Validation.a(this.g.c(), var2.e(), 0, var2.getType(), var13, var14));
         }

         var12 += 2;

         for(int var10 = 0; var10 < (var9 & '\uffff'); ++var10) {
            CellArea var11 = this.a(var1, var12);
            var12 += 8;
            com.aspose.cells.b.a.a.ze.a(var2.getAreaList(), (Object)var11);
         }

         return var2;
      }
   }

   private CellArea a(byte[] var1, int var2) {
      CellArea var3 = new CellArea();
      var3.StartRow = com.aspose.cells.b.a.zc.e(var1, var2) & '\uffff';
      var2 += 2;
      var3.EndRow = com.aspose.cells.b.a.zc.e(var1, var2) & '\uffff';
      var3.StartColumn = var1[var2 + 2] & 255;
      var3.EndColumn = var1[var2 + 4] & 255;
      var2 += 6;
      return var3;
   }

   private String a(byte[] var1, int[] var2) throws Exception {
      int var3 = com.aspose.cells.b.a.zc.e(var1, var2[0]);
      if ((var3 & '\uffff') == 0) {
         var2[0] += 3;
         return null;
      } else if ((var3 & '\uffff') != 0 && ((var3 & '\uffff') != 1 || var1[var2[0] + 2] != 0 || var1[var2[0] + 3] != 0)) {
         var2[0] += 2;
         if (var1[var2[0]] != 0) {
            String var6 = Encoding.getUnicode().a(var1, var2[0] + 1, 2 * (var3 & '\uffff'));
            var2[0] += 2 * (var3 & '\uffff') + 1;
            return var6;
         } else {
            byte[] var4 = new byte[2 * (var3 & '\uffff')];

            for(int var5 = 0; var5 < (var3 & '\uffff'); ++var5) {
               var4[2 * var5] = var1[var2[0] + var5 + 1];
            }

            var2[0] += (var3 & '\uffff') + 1;
            return Encoding.getUnicode().a(var4);
         }
      } else {
         var2[0] += 4;
         return null;
      }
   }
}
